package com.zhihaihe.file.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;


import javax.persistence.*;
import java.util.List;

/**
 * 用户基础信息类
 * @author
 */
@Data
@Entity
@TableName("user")
public class UserBean {
    @Id
    @TableId(type = IdType.AUTO)
    private Long userId;

    private String openId;

    private String username;

    private String realname;

    private String password;

    private String qqPassword;

    private String telephone;

    private String email;

    private String sex;


    private String birthday;

    private String addrProvince;

    private String addrCity;

    private String addrArea;

    private String industry;

    private String position;

    private String intro;
    /**
     * 加密密码的盐
     */
    private String salt;
    //private byte state;//用户状态,0:创建未认证（比如没有激活，没有输入验证码等等）--等待验证的用户 , 1:正常状态,2：用户被锁定.

    private String imageUrl;

    private String registerTime;


    /**
     * 验证码
     */
    @Transient
    @TableField(exist = false)
    private String verificationCode;

    @Transient
    @TableField(exist = false)
    private String token;

    /**
     * 角色列表
     *  立即从数据库中进行加载数据
     */
    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "user_role",
            joinColumns = {@JoinColumn(name = "userId")},
            inverseJoinColumns = {@JoinColumn(name = "roleid")})
    @TableField(exist = false)
    /**
     *  一个用户具有多个角色
     */
    private List<Role> roleList;
}
